/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Bean;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Reynusa
 */
public class PesanBrgKc {
    private String kodetoko;
    private String kodebarang;
    private String nama;
    private int jumlah;
    private String tglpesan;
    
    public PesanBrgKc(){
        
    }
    public int getJumlah() {
        return jumlah;
    }

    public void setJumlah(int jumlah) {
        this.jumlah = jumlah;
    }

    public String getKodebarang() {
        return kodebarang;
    }

    public void setKodebarang(String kodebarang) {
        this.kodebarang = kodebarang;
    }

    public String getKodetoko() {
        return kodetoko;
    }

    public void setKodetoko(String kodetoko) {
        this.kodetoko = kodetoko;
    }

    public String getNama() {
        return nama;
    }

    public void setNama(String nama) {
        this.nama = nama;
    }

    public String getTglpesan() {
        return tglpesan;
    }

    public void setTglpesan(String tglpesan) {
        this.tglpesan = tglpesan;
    }
   public List lihatbarang() throws SQLException {
        List spesankc = new ArrayList();
        Connection conn = DataBaseConnection.open("jdbc:oracle:thin:@172.23.9.185:1521:orcl", "mhs115314009", "mhs115314009");
        String retrieveQuery = "select * from tabelpesan";
        Statement st = conn.createStatement();
        ResultSet rs = st.executeQuery(retrieveQuery);
        while (rs.next()) {
            PesanBrgKc pesan = new PesanBrgKc();
            pesan.setKodetoko(rs.getString("kodetoko"));
            pesan.setKodebarang(rs.getString("kodebarang"));
            pesan.setJumlah(Integer.parseInt(rs.getString("jumlah")));
            pesan.setTglpesan(rs.getString("tglpesan"));
            spesankc.add(pesan);
        }
        conn.commit();
        return spesankc;
    }
}
